<?php

class Core_Frontend_Component_Subject_Controller_Content extends Core_Frontend_Share_Component_Controller {

    public function detailAction($id = NULL) {
        if(!$id){$id = 1;}
        $subject = App::getModel('subject/content')->load($id)->updateClickCount();
        $themeId = $subject->getThemeId();
        if(empty($themeId)){
           $themeId = $subject->getCategory()->getThemeId();
        }
        $pageTemplate = App::getModel('design/collection_page_template')
                ->filterByPageThemeId($themeId)
                ->filterByFileName('detail')
                ->filterByEnabled(1)
                ->load()
                ->getFirstItem();
        $this->getVariables()->setData('page_template', $pageTemplate);
        $this->getVariables()->setData('subject_object', $subject);
        Kd_Web::getPage()->getNavigation()->addLabel('文章主题')->addLabel($subject->getName());
        Kd_Web::getPage()->setTitle($subject->getName())
                ->setKeyword($subject->getTag())
                ->addMeta('name', 'description', $subject->getIntroduction());
        return $this->pageResult($pageTemplate,array('subject'=>$subject));
    }

    public function previewAction($id){
        if($this->getSession()->has('is_subject_preview')){
            return $this->redirectResult(array('id'=>$id),'detail');
            $this->getSession()->remove('is_subjectt_preview');
        }
        die('非法操作');
    }

}